package com.example.service.shenhe.impl;

import com.example.dao.shenhe.Shcourse;
import com.example.pojo.CourseRecord;
import com.example.service.shenhe.Shcourseservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

import static java.lang.Integer.parseInt;

/**
 * @ClassName: ***
 * @Description: ***
 * @author: ***
 * @date: 2022/12/9 13:37
 */
@Service
public class Shcourseserviceimpl implements Shcourseservice {
    @Autowired
    private Shcourse shcourse;

    /**
    * @Author: zdp
    * @Description: 未审核课程
    * @DateTime: 13:39 2022/12/9
    * @Params:
    * @Return
    */
    public List call(){
        return shcourse.call();
    }

    /**
    * @Author: zdp
    * @Description: 查询课程分类
    * @DateTime: 15:34 2022/12/12
    * @Params:
    * @Return
    */
    public List courseclass(){
        return shcourse.courseclass();
    }
    /**
    * @Author: zdp
    * @Description: 模糊查
    * @DateTime: 10:52 2022/12/13
    * @Params:
    * @Return
    */
    public List check(String courseName, String name, int courseNprice){
        return shcourse.check(courseName,name,courseNprice);
    }
    /**
    * @Author: zdp
    * @Description: 审核课程，修改课程审核状态、添加审核记录表
    * @DateTime: 11:50 2022/12/16
    * @Params:
    * @Return
    */
    public int shenhe(CourseRecord courseRecord){
        int a = 0;
        String result = courseRecord.getResult();
        if(result.equals("审核不通过")){
            a=5;
        }else{
            a=6;
        }
        int zhuangtai = shcourse.zhuangtai(a, courseRecord.getCourseId());
        int shehe = shcourse.shenhe(courseRecord);
        if(zhuangtai>0&&shehe>0){
            return 2;
        }
        return 1;
    }
}
